class Student:
    def __init__(self, name, age, score):
        self.name = name
        self.__age = age
        self.score = score

    # 使用装饰器 @property 修改方法，将方法转成属性使用
    @property
    def get_age(self):
        return self.__age

    @get_age.setter
    def set_age(self, age):
        self.__age = age

    def show(self):
        print(self.name, self.__age, self.score)


if __name__ == '__main__':
    stu = Student('马迪迪', 23, 67.5)
    stu.show()
    print(stu.get_age)
    print("直接访问的方式")
    print(stu._Student__age)
    stu.set_age = 26
    print(stu.get_age)
    # stu.age = 1
    stu.show()
